<%
  var tab = $this.query.tab || '';
  var count1 = yield $Topic.getTopicsCount(tab);
  var count2 = yield $Scrape.getScrapeCount(tab);
  var count = count1 + count2;
  var pages = Math.ceil(count / 10);
  var page = +$this.query.p || 1;
  var its = [page-2, page-1, page, page+1, page+2];
  var prePage = '?tab=' + tab + '&p=' + (page - 1);
  var nextPage = '?tab=' + tab + '&p=' + (page + 1);
%>
<div class="ui pagination menu">
  <% if (page && page > 1) { %>
    <a class="icon item" href="?tab=<%= tab %>&p=<%= page - 1 %>">
      <i class="left arrow icon"></i>
    </a>
  <% } %>
  <% its.forEach(function (item) { %>
    <% if (item && (item > 0) && (item <= pages) && (pages > 1)) { %>
      <a class="<%= (page == item) ? 'active': '' %> item" href="?tab=<%= tab %>&p=<%= item %>"><%= item %></a>
    <% } %>
  <% }); %>

  <% if (page && page < pages) { %>
    <a class="icon item" href="?tab=<%= tab %>&p=<%= page + 1 %>">
      <i class="right arrow icon"></i>
    </a>
  <% } %>
</div>